package cn.com.git.example.common;

import cn.com.git.example.common.base.BaseResult;
import cn.com.git.example.common.base.BaseResultConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangzhenfu
 * @Description
 * @date 2020/4/3 15:25
 */
@Data
@ApiModel
public class ResultPage<D> extends BaseResult implements Serializable {
    @ApiModelProperty(value = "总页数")
    private int total;
    @ApiModelProperty(value = "当前页")
    private int page;
    @ApiModelProperty(value = "总记录数")
    private long records;
    @ApiModelProperty(value = "数据集")
    private List<D> rows;

    public ResultPage() {
        super();
    }

    public ResultPage(BaseResultConstant baseResultConstant) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), baseResultConstant.getMessage());
        this.rows = new ArrayList<>();
    }

    public ResultPage(BaseResultConstant baseResultConstant, String message) {
        super(baseResultConstant.getCode(), message);
        this.rows = new ArrayList<>();
    }

    public ResultPage(BaseResultConstant baseResultConstant, List<D> data, long count) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), baseResultConstant.getMessage());
        this.rows = data;
        this.records = count;
    }


}
